import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//路由信息数据
const routes = [
  {
    //登陆页面
    path:'/login',
    meta: { title: '登录' },
    component:()=>import('@v/login.vue')
  }, {
    //登陆页面
    path:'/changePassword',
    meta: { title: '修改密码' },
    component:()=>import('@v/ChangePassword.vue')
  },{
    //后台主页
    path:'/',
    name:'main',
    component:()=>import('@v/layout/Layout1.vue'),
    children:[
      {
        path:'',
        name:'page',
        meta:{title:'首页'},
        component:()=>import('@v/workbench/Workbench.vue')
      },
      {
        path:'user',
        name:'user',
        meta:{title:'用户管理'},
        component:()=>import('@v/user/User.vue')
      },
      {
        path:'dept',
        name:'dept',
        meta:{title:'组织管理'},
        component:()=>import('@v/dept/Dept.vue')
      },
      {
        path:'position',
        name:'position',
        meta:{title:'岗位管理'},
        component:()=>import('@v/position/Position.vue')
      },
      {
        path:'role',
        name:'role',
        meta:{title:'角色管理'},
        component:()=>import('@v/role/Role.vue')
      },
      {
        path:'resource',
        name:'resource',
        meta:{title:'资源管理'},
        component:()=>import('@v/resource/Resource.vue')
      },
      {
        path:'dic',
        name:'dic',
        meta:{title:'数据字典'},
        component:()=>import('@v/dic/Dic.vue')
      },
      {
        path:'parameter',
        name:'parameter',
        meta:{title:'系统参数'},
        component:()=>import('@v/parameter/Parameter.vue')
      },
      {
        path:'system',
        name:'system',
        meta:{title:'系统管理'},
        component:()=>import('@v/system/System.vue')
      },
      {
        path:'ico',
        name:'ico',
        meta:{title:'ICO图标'},
        component:()=>import('@v/system/Ico.vue')
      },
      {
        path:'workDate',
        name:'workDate',
        meta:{title:'工作日历'},
        component:()=>import('@v/system/fworkday.vue')
      },
      {
        path:'notification',
        name:'notification',
        meta:{title:'通知管理'},
        component:()=>import('@v/system/Notification.vue')
      },
      {
        path:'workbench',
        name:'workbench',
        meta:{title:'工作台'},
        component:()=>import('@v/workbench/Workbench.vue')
      },
      {
        path:'loginLog',
        name:'loginLog',
        meta:{title:'登录日志'},
        component:()=>import('@v/syslog/LoginLog.vue')
      },
      {
        path:'operateLog',
        name:'operateLog',
        meta:{title:'操作日志'},
        component:()=>import('@v/syslog/OperateLog.vue')
      },
      {
        path:'process',
        name:'process',
        meta:{title:'流程设计'},
        component:()=>import('@v/process/Process.vue')
      },
      {
        path:'interface',
        name:'interface',
        meta:{title:'接口管理'},
        component:()=>import('@v/process/Interface.vue')
      },
      {
        path:'processInstance',
        name:'processInstance',
        meta:{title:'流程实例'},
        component:()=>import('@v/process/ProcessInstance.vue')
      },
      {
        path:'todo',
        name:'todo',
        meta:{title:'我的待办'},
        component:()=>import('@v/todo/ToDo.vue')
      },
      {
        path:'agent',
        name:'agent',
        meta:{title:'代理用户'},
        component:()=>import('@v/useragent/UserAgent.vue')
      },
      {
        path:'online',
        name:'online',
        meta:{title:'在线用户'},
        component:()=>import('@v/control/online/Online.vue')
      },
      {
        path:'admin-control',
        name:'admin-control',
        meta:{title:'管理员监控'},
        component:()=>import('@v/control/adminControl/AdminControl.vue')
      },
      {
        path:'cache-control',
        name:'cache-control',
        meta:{title:'缓存监控'},
        component:()=>import('@v/control/cacheControl/CacheControl.vue')
      },
      {
        path:'schedulers',
        name:'schedulers',
        meta:{title:'定时任务'},
        component:()=>import('@v/control/schedulers/Schedulers.vue')
      }
    ]
  },
  {
    path:'/editor',
    name:'editor',
    meta:{title:'流程设计器'},
    component:()=>import('@v/process/processEditor/Editor.vue')
  },
  {
    path:'/reimburse',
    name:'reimburse',
    meta:{title:'报销流程'},
    component:()=>import('@v/reimburseInstance/ReimburseProcess.vue')
  },
  {
    path:'*',
    component:()=>import('@v/error.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router
